<!doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" Content="text/html; charset=utf-8"/>

	<link rel="stylesheet" type="text/css" href="../css/header.css">
	<link rel="stylesheet" type="text/css" href="../css/footer.css">
	<link rel="stylesheet" type="text/css" href="../css/contest_list.css">
	<link rel="stylesheet" href="../res/bootstrap/css/bootstrap.min.css">
	<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.1.js"></script>
	<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.js"></script>
	<script src="//netdna.bootstrapcdn.com/bootstrap/2.3.2/js/bootstrap.min.js"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script>
	<script src="../myUtil.js"></script>

<script> 
    $(function(){
      $(".header").load("header.html"); 
	  $(".footer").load("footer.html"); 
    });
    var myModule = angular.module('myModule', []);

    myModule.controller('MyController', function ($scope, $http,$location) {
        
        $scope.contest_reg={};
        $scope.authority={};
        $scope.loadData = function() {
        	myUtil.onHttp($http,'get','contest_list.do',null,null,
        			function(data){
        				$scope.contest_reg=data;
        			}
        	)
        	myUtil.onHttp($http,'get','userAuthority.do',null,null,
        			function(data){
        				$scope.authority=data.authority;
        			}
        	)
        }
        $scope.goContest =function(contest_reg_id){
        	location.href="contest.html#?contest_reg_id="+contest_reg_id;
        }
        
     	$scope.logout =function(){
     		location.href="logout.do";
     	}
     	
        $scope.loadData();

        
        
        
    });
</script> 

</head>

<body ng-app="myModule">
<div class="container" ng-controller="MyController">
<div class="header span12"></div>
<h1>대회</h1> 새회관련 페이지입니다. <a class="btn btn-primary" ng-if="authority=='ROLE_ADMIN'" href="createContest.html">대회생성</a>
<a class="btn btn-primary" ng-if="authority=='ROLE_ADMIN'" href="accessContest.html" >참가신청승인</a>
<a class="btn btn-primary" ng-if="authority=='ROLE_ADMIN'" href="skillControl.html" >구현기술 관리</a>
	<br/><br/>
<table class="table table-condensed">
		<thead>
			<tr>
				<td>접수 신청일</td>
				<td>접수 마감일</td>
				<td>회차</td>
				<td>경진대회명</td>
				<td>대회 마감일</td>
				<td>내용 보기</td>
				<td>신청</td>
			</tr>
		</thead>
		
		<tbody ng-repeat="(key,val) in contest_reg" ng-if="val.length!=0">
			<tr ng-repeat="item in val" ng-style="{'background-color':item.color}" ng-click="goContest(item.contest_reg_id)">
				<td>{{item.apply_start_date}}</td>
				<td>{{item.apply_end_date}}</td>
				<td>{{item.count}}</td>
				<td>{{item.name+item.count+"회차"}}</td>
				<td>{{item.enddate}}</td>
				<td>{{item.color}}</td>
				<td><a class="btn" ng-if="key=='b_apply'" href="apply.html#?contest_reg_id={{item.contest_reg_id}}">신청하기</a></td>
				
			</tr>
		</tbody>

	</table>


<div class="footer span12"></div>
</div>
</body>
</html>